#ifndef _OPENGL_RENDERER_H
#define _OPENGL_RENDERER_H

//OpenGL headers
#include <gl\gl.h>			// Header File For The OpenGL32 Library
#include <gl\glu.h>			// Header File For The GLu32 Library
//#include <gl\glaux.h>		// Header File For The Glaux Library

#include "Vector3D.h"

//Standard library headers
#include <windows.h>
#include <vector>

//The gl header doesn't contain this define from newer versions of OpenGL
#define GL_CLAMP_TO_EDGE 0x812F

	//Window callback
	LRESULT CALLBACK WndProc(	HWND	hWnd,			// Handle For This Window
								UINT	uMsg,			// Message For This Window
								WPARAM	wParam,			// Additional Message Information
								LPARAM	lParam);		// Additional Message Information
	
	class CRenderer
	{
		
		public:
			
			//Constructor and destructor
		    CRenderer(); 
			~CRenderer() 		{ if (hWnd) KillWindow(); } //TODO: Check if needed here or after main loop
			
			//Main functions
			bool 	CreateRendererWindow(char* Title, int Width, int Height, int Bits, bool Fullscreen);
			void 	ResizeScene(int Width, int Height);
			void 	KillWindow();
			bool 	DrawScene();
			
			void DrawQuad(Vector3D Pos, Vector3D Size, bool Filled = true, Vector3D TexStretch = Vector3D(1, 1, 1));
			
			bool	CheckMessages();
			
			//Variable access functions
			unsigned int 	getWidth()				{ return width; }
			unsigned int 	getHeight()				{ return height; }
			Vector3D		getViewSize()			{ return Vector3D(width, height); }
			HWND 			getWindowHandle()		{ return hWnd; }
			HDC				gethDC()				{ return hDC; }
			bool 			isActive()				{ return active; }
			void			setActive(bool value)	{ active = value; }
			bool 			isQuit()				{ return quit; }
			void		 	setQuit(bool value)		{ quit = value; }
			
			//Rendering functions 
			//void drawVertexList(ODN_Vertex* vertices, int vertexcount
			
		private:
			
			//General variables
			bool 			fullscreen;
			unsigned int 	width;
			unsigned int 	height;
			
			//Window variables
			HGLRC		hRC;		// Permanent Rendering Context
			HWND		hWnd;		// Holds Our Window Handle
			HINSTANCE	hInstance;	// Holds The Instance Of The Application
			HDC				hDC;		//Private GDI Device Context
			bool 			active;		//Is the windows active?
			bool 			quit;		//Have we received a quit message? 
			
			//Renderer initialisation
			bool 	Init();
		
	};
	
	//Function to find a renderer instance from a given hWnd 
	CRenderer* getRendererFromWindowHandle(HWND hWnd);

#endif //_OPENGL_RENDERER_H 
